package edu.chl.johanwi.jsfproducts;
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author Schtohan
 */
@ManagedBean
@RequestScoped
public class addProductControllerBean {
    
    @NotNull
    @Size(min=3)
    private String name;
    private String cat;
    @Min(value=3)
    private double price;

    /** Creates a new instance of addProductControllerBean */
    public addProductControllerBean() {              
        
    }

    public String getCat() {
        return cat;
    }

    public void setCat(String cat) {
        this.cat = cat;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }
    
    public String doAddProduct(){
        
        Product p = new Product(name, cat, price);
        Database.getProductController().create(p);  
        return "onAddProduct";
        
    }
  
}
